package com.margo.project.redis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.margo.project.redis.model.RedisModel;
import com.margo.project.redis.service.RedisValueOperationsServiceImpl;

@Controller
@RequestMapping(value = "/sw/mobile/mobileservice/redisValueOperationsController")
public class RedisValueOperationsController {

    @Autowired
    private RedisValueOperationsServiceImpl service;
	   //添加
    @RequestMapping(value = "/add", method = RequestMethod.GET)
    @ResponseBody
    public Object add() {
        System.out.println("start.....");
        RedisModel m = new RedisModel();
        m.setName("张三");
        m.setTel("1111");
        m.setAddress("深圳1");
        m.setRedisKey("zhangsanKey01");
        service.put(m.getRedisKey(), m, -1);

        RedisModel m2 = new RedisModel();
        m2.setName("张三2");
        m2.setTel("2222");
        m2.setAddress("深圳2");
        m2.setRedisKey("zhangsanKey02");
        service.put(m.getRedisKey(), m2, -1);

        return "ok";
    }
    
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    @ResponseBody
    public Object get(){
    	return service.get("zhangsanKey01");
    }
}
